//
//  QJMineTXVC.m
//  QuanJieShopProject
//
//  Created by 刘中义 on 2018/2/28.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "QJMineTXVC.h"
#import "QJMineTXJLVC.h"
@interface QJMineTXVC ()<UITextFieldDelegate>

@end

@implementation QJMineTXVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = @"提现";
    self.txTF.delegate = self;
    self.yueLabel.text = self.ktxStr;
    self.oneBtn.layer.cornerRadius = 15.0;
    self.oneBtn.layer.masksToBounds = YES;
    self.oneBtn.layer.borderColor = HexRGB(0x0589E8).CGColor;
    self.oneBtn.layer.borderWidth = 1.0;
    self.twoBtn.layer.cornerRadius = 3.0;
    self.twoBtn.layer.masksToBounds = YES;
    
    self.threeBtn.layer.cornerRadius = 3.0;
    self.threeBtn.layer.masksToBounds = YES;
    self.threeBtn.layer.borderColor = HexRGB(0xe6e6e6).CGColor;
    self.threeBtn.layer.borderWidth = 1.0;
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    //控件不被导航栏遮挡
    self.navigationController.navigationBar.translucent = NO;
}
- (IBAction)txVCBtnClickAction:(UIButton *)sender {
    NSInteger tag = sender.tag;
    switch (tag) {
        case 200:
        {
            self.txTF.text = [NSString stringWithFormat:@"%@",self.yueLabel.text];
            self.tipLabel.hidden = NO;
        }
            break;
        case 201:
        {

            NSString *txStr = [NSString stringWithFormat:@"%@",self.txTF.text];
            NSString *yueStr = [NSString stringWithFormat:@"%@",self.yueLabel.text];
            if (txStr.length > 0) {
                if ([txStr compare:yueStr] == NSOrderedDescending) {
                    [MBPHUD showAlertWithTitle:@"您输入的金额不对!"];
                }else if([txStr compare:@"100"] == NSOrderedAscending){
                    [MBPHUD showAlertWithTitle:@"提现金额不能少于100!"];
                }else{
                    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
                    [dict setValue:txStr forKey:@"money"];
                    
                    [WWNetRequest fetchSqtxWithParameters:dict success:^(id response) {
                        
                        NSLog(@"提现申请成 response = %@", response);
                        [MBPHUD showAlertWithTitle:@"提现申请成功!"];
                        CGFloat yue = [yueStr floatValue];
                        CGFloat tx = [txStr floatValue];
                        self.yueLabel.text = [NSString stringWithFormat:@"%.2f",yue - tx];
                    } failure:^(NSDictionary *error) {
                        NSLog(@"提现申请成 error = %@", error);
                    }];
                }
            }else{
                [MBPHUD showAlertWithTitle:@"请输入提现金额!"];
            }
        }
            break;
        case 202:
        {
            QJMineTXJLVC *VC = [[QJMineTXJLVC alloc]init];
            KPushViewControllerAction(VC);
            
        }
            break;
            
        default:
            break;
    }
}
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
    
     self.tipLabel.hidden = NO;
    return YES;
}


@end
